package com.tanhua.autoconfig;

import com.tanhua.autoconfig.properties.AipFaceProperties;
import com.tanhua.autoconfig.properties.OssProperties;
import com.tanhua.autoconfig.properties.SmsProperties;
import com.tanhua.autoconfig.template.AipFaceTemplate;
import com.tanhua.autoconfig.template.OssTemplate;
import com.tanhua.autoconfig.template.SmsTemplate;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

//相当于将SmsProperties交给容器
@EnableConfigurationProperties(
        value={
                SmsProperties.class,
                OssProperties.class,
                AipFaceProperties.class
        }
)
public class TanhuaAutoConfiguration {

    /**
     * 指定自动装配的类
     *  将SmsTemplate存入Spring容器
     *  @Bean：如果有参数，从容器中查找对象，调用方法
     */
    @Bean
    public SmsTemplate smsTemplate(SmsProperties properties) {
        return new SmsTemplate(properties);
    }

    @Bean
    public OssTemplate ossTemplate(OssProperties properties){
        return new OssTemplate(properties);
    }

    @Bean
    public AipFaceTemplate aipFaceTemplate(AipFaceProperties properties){
        return new AipFaceTemplate(properties);
    }
}
